package com.xbongbong.saas.model;

import com.xbongbong.paas.toolbox.exception.XbbException;
import com.xbongbong.paas.toolbox.wrap.IModel;
import com.xbongbong.pro.domain.entity.ScoreRuleEntity;
import org.apache.ibatis.annotations.Param;

import java.util.List;
import java.util.Map;

/**
 * @author chunyang.qin
 * @Title: 评分规则实现类
 * @date 2020/11/27 14:58
 */
public interface ScoreRuleModel extends IModel<ScoreRuleEntity> {
    @Override
    Integer insert(ScoreRuleEntity entity) throws XbbException;

    @Override
    Integer update(ScoreRuleEntity entity) throws XbbException;

    @Override
    List<ScoreRuleEntity> findEntitys(Map<String, Object> param);

    @Override
    Integer getEntitysCount(Map<String, Object> param);

    ScoreRuleEntity getByKey(@Param("key") Long key, @Param("corpid") String corpid);
    //根据formId查询"启用" 状态的评分规则
    ScoreRuleEntity getByFormId(@Param("formId") Long formId, @Param("corpid") String corpid);

    Integer deleteByKey(@Param("key") Long key, @Param("corpid") String corpid);

    /**
     * 判读该表单下是否有 启用的评分区间
     * @param corpid
     * @param formId
     * @return
     * @throws XbbException
     */
    Boolean haveEnabledScoreRule(String corpid , Long formId) throws XbbException;

    Boolean setEnabledScoreRule2Redis(String corpid , Long formId , Integer value) throws XbbException;
}
